/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.nxlv2.nomad.view.ficheClient;

import com.nxlv2.nomad.businessobjects.Client;
import com.nxlv2.nomad.view.Welcome;
import java.awt.event.ActionEvent;
import java.util.List;
import javax.swing.AbstractAction;

/**
 *
 * @author Administrateur
 */
public class FicheClientAction extends AbstractAction {
    private final Welcome welcomeUI;

    public FicheClientAction(Welcome welcomeUI) {
        super();
        this.welcomeUI = welcomeUI;
    }

    @Override
    public void actionPerformed(ActionEvent e) {

        if(!"".equals(welcomeUI.getClientSelect())){
            List<Client> clients = welcomeUI.getUser().getListClient();
            Client cl = null;
            for(int i = 0; i < clients.size(); i++){
                if(clients.get(i).getNom().equals(welcomeUI.getClientSelect())){
                    cl = clients.get(i);
                    break;
                }
            }
            if(cl != null){
                FicheClient ficheClientUI = new FicheClient(cl, welcomeUI);
                ficheClientUI.setVisible(true);
            }
        } else {
            System.out.println("Pas de client selectionné !");
        }
    }
    
}
